package com.example.test;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import com.example.test.bean.GW;
import com.example.test.bean.MySQLiteOpenHelper_1;
import com.example.test.util.ToastUtil;

public class TWActivity extends AppCompatActivity {
    private EditText carNumber,date_2,w_2;
    private MySQLiteOpenHelper_1 mySQLiteOpenHelper_1;
    String CarNumber,Date_2,W_2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tw);
        initView();
        mySQLiteOpenHelper_1 = new MySQLiteOpenHelper_1(this);
    }
    private void initView(){
        carNumber = findViewById(R.id.carNumber);
        date_2 = findViewById(R.id.date_2);
        w_2 = findViewById(R.id.w_2);
    }

    public void update(View view){
        CarNumber = carNumber.getText().toString().trim();
        Date_2 = date_2.getText().toString().trim();
        W_2 = w_2.getText().toString().trim();

        GW gw =new GW();
        gw.setCarNumber(CarNumber);
        gw.setDate_2(Date_2);
        gw.setW_2(W_2);

        long rowId = mySQLiteOpenHelper_1.updateData(gw);
        if (rowId >0) {
            ToastUtil.toastShort(this, "添加成功！");
        } else {
            ToastUtil.toastShort(this, "没有数据被添加");
        }
    }



}